package com.tc.mapper;

import com.tc.dto.Category;
import com.tc.dto.Food;
import com.tc.myDto.BusinessShop;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface HomeMapper {
    //获取推荐菜品信息
    @Select("select * from user_base_information where business_name is not null ")
    List<BusinessShop> randomRecommend();
    //根据商家名称获取所有菜品分类
    @Select("select * from category where belong_user=#{param1} and type=#{param2} order by sort")
//    @Select("select * from category where belong_user=#{param1} order by sort")
    List<Category> selectBusinessName(String name, String type);
    //根据分类获取
    @Select("select * from studytakeawayweb.food where belong_user=#{belongUser} and belong_category=#{name} and state=1")
//    @Select("select * from studytakeawayweb.food where belong_user=#{belongUser} and state=1")
    List<Food> getFoodByCategory(Category category);
    //判断店铺是否存在
    @Select("select business_name from user_base_information where business_name=#{shopName}")
    String checkShopName(String shopName);
    //新增店铺
    @Insert("insert into user_base_information(username, password, business_name, img, bgImg) values(#{username},#{password},#{businessName},#{img},#{bgImg})")
    void addShop(BusinessShop build);
    //获取对应商家的所有菜品
    @Select("select * from studytakeawayweb.food where belong_user=#{businessName}")
    List<Food> getAllFood(String businessName);
}
